<?php 
	include_once 'dataservice.php';
	include_once 'thuvienham.php';

	class hoadonquyen_db 
	{
		public function Them($MaQuyenHoaDon, $NgayMo)
		{
			$sql = "INSERT INTO `tbl_hoadonquyen`(`MaQuyenHoaDon`, `NgayMo`)
					VALUES ('$MaQuyenHoaDon', '$NgayMo')";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function Xoa($MaQuyenHoaDon)
		{
			$sql = "DELETE FROM `tbl_hoadonquyen` WHERE `MaQuyenHoaDon` = '$MaQuyenHoaDon'";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function CapNhat($MaQuyenHoaDon, $NgayMo)
		{
			$sql = "UPDATE `tbl_hoadonquyen`
					SET `NgayMo` = '$NgayMo'
					WHERE `MaQuyenHoaDon` = '$MaQuyenHoaDon'";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function LayDanhSach($MaQuyenHoaDon, $NgayMo)
		{
			$sql = "SELECT * FROM `tbl_hoadonquyen` WHERE 1  ";
			if($MaQuyenHoaDon != -1)
				$sql .= " AND `MaQuyenHoaDon` = '$MaQuyenHoaDon' ";

			if($NgayMo != "0000-00-00")
				$sql .= " AND `NgayMo` = '$NgayMo' ";

			$service = new dataservice();
			return $service->ExecuteQuery($sql);
		}

	}

